package com.dimples.dd.gateway;

import com.dimples.dd.gateway.route.DynamicRouteLoader;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * @author zhongyj <1126834403@qq.com><br/>
 * @date 2024/5/22
 */
@Slf4j
@SpringBootApplication
public class DDGatewayApplication implements CommandLineRunner {

    @Resource
    private DynamicRouteLoader dynamicRouteLoader;

    public static void main(String[] args) {
        // 启动 Spring Boot 应用
        SpringApplication.run(DDGatewayApplication.class, args);
    }

    /**
     * 容器初始化后加载路由
     * @param args args
     */
    @Override
    public void run(String... args) {
       dynamicRouteLoader.refresh(null);
    }
}
